**************************************************************
****** 					Master do file					****** 
******  "Trade and US Inequality in the Tokyo Round" 	******
****** Andrew Greenland, James Lake, and John Lopresti 	******
****** 		Review of Economics and Statistics 2026		******
**************************************************************


* Note: Please see the replication packages readme file for
*		further information


*************
**# 1. Setup 
*************

*****************************
**## 1a. Paths & Directories
*****************************
* Paths
if "`c(username)'"==" "    global path "/restatReplicationPackage"

* Directories
global code 		"$path/code"
global data 		"$path/data"
global raw 		 	"$path/data/raw"
global processing 	"$path/data/processing"
global analysis  	"$path/data/analysis"
global results   	"$path/tables"
global figures   	"$path/figures" 

cd 					"$data"


******************
**## 1b. Packages
******************
* All packages except ivreghdfe & its dependencies
loc packages "unique egenmore mmerge ereplace estout"
loc packages "`packages' ranktest quantiles"
foreach p in `packages' {
cap which `p'
if _rc!=0 {
	ssc install `p'
	noi di "Installed package `p'"
}
else {
	noi di "Package `p' already installed"
}

}	
cap ado uninstall grc1leg
net install grc1leg, from(http://www.stata.com/users/vwiggins) 

* ivreghdfe and dependencies
cap ado uninstall require
ssc install require
cap ado uninstall ftools
net install ftools, from("https://raw.githubusercontent.com/sergiocorreia/ftools/master/src/")
cap ado uninstall reghdfe
net install reghdfe, from("https://raw.githubusercontent.com/sergiocorreia/reghdfe/master/src/")
cap ado uninstall ivreg2
ssc install ivreg2
cap ado uninstall ivreghdfe
net install ivreghdfe, from("https://raw.githubusercontent.com/sergiocorreia/ivreghdfe/master/src/")



****************************
**# 2. Dataset construction
****************************

**********************
**## 2a. Concordances
**********************
do "$code/2a_concordances.do"

	
********************
**## 2b. 1930s data 
********************
do "$code/2b_1930s_data.do"	


*************************************
**## 2c. Foreign Country Tariff Cuts
*************************************
do "$code/2c_reciporical_tariffs.do"


*****************************
**## 2d. Lagged Price Growth
*****************************
do "$code/2d_construct_sic_price_growth.do"


********************
**## 2e. MFA Shares
********************
do "$code/2e_construct_mfa_shares.do"


********************
**## 2f. IPUMS Data
********************
do "$code/2f_import_ipums.do"

			
*********************
**## 2g. Routineness
*********************
do "$code/2g_construct_routineness.do"

			
********************
**## 2h. Automation
********************
do "$code/2h_construct_automation.do"

	
***********************
**## 2i. SIC87 Dataset
***********************
do "$code/2i_sic87_dataset_creation.do"


****************************
**## 2j. SIC Women's Shares
****************************
do "$code/2j_construct_women_shares.do"

							
********************************
**## 2k. SIC Regression Dataset
********************************
do "$code/2k_sic_regression_dataset_creation.do"

	
**********************************
**## 2l. IPUMS Regression Dataset
**********************************
do "$code/2l_ipums_regression_dataset_creation.do" 
	  
	
****************
**# 3. Analysis
****************

**********************
**## 3a. SIC Analysis
**********************
do "$code/3a_sic_Analysis.do"
				
					
************************
**## 3b. IPUMS Analysis
************************
do "$code/3b_ipums_analysis.do"

	
*****************************
**## 3c. Additional Analysis
*****************************
do "$code/3c_additional_analysis.do"	
			